<?php

function logged_in_redirect() {
    if (logged_in() === 1) {
        header('Location: index.php');
        exit();
    }
}

function protect_page() {
    if (logged_in() === 0){
        header('Location: protected.php');
        exit();
    }
}

	function logged_in() {
    return (isset($_SESSION['user_id'])) ? 0 : 1;
}

?>